//
// Created by 86176 on 2021/11/27.
//

#include "ProtocolCodecFactory.h"

bool ProtocolCodecFactory::getMessage(Session *pSession, IoBuffer *ioBuffer, Message *pMessage) {
    return this->doDeCode(pSession,ioBuffer,pMessage);
}

bool ProtocolCodecFactory::doDeCode(Session *pSession, IoBuffer *ioBuffer, Message *pMessage) {
    bool markPoint = true;
    Message *message;
    while (true){
        message = this->deCode(pSession,ioBuffer);
        if(NULL == message) break;
        if(true == markPoint) markPoint = false;
        this->callNextMessageRecevide(pSession,message);
    }
    pMessage = NULL;
    return markPoint;
}

bool ProtocolCodecFactory::doEnCode(Session *pSession, IoBuffer *ioBuffer, Message *pMessage) {
    //todo 调用编码api
    return false;
}
